<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item><i class="el-icon-date"></i>团队信息设置</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
    
     <el-form label-width="80px">
      
    <el-form-item label="战队名:">
    <el-input v-model="unewdata.owe_group_title" auto-complete="off"  placeholder="战队名称" class="handle-input"></el-input>
    </el-form-item>
    <el-form-item label="封面图:">
   <el-upload class="avatar-uploader" name='image' :action="uploadURI"  :show-file-list="false" :on-success="handleCoverSuccess">
   <img v-if="unewdata.owe_show_group_img" :src="unewdata.owe_show_group_img" class="avatar">
    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  </el-upload>
<el-dialog :visible.sync="dialogVisible" size="tiny">
  <img width="100%" :src="dialogImageUrl" alt="">
</el-dialog>
    </el-form-item>

      <el-form-item label="队标:">
   <el-upload class="avatar-uploader" name='image' :action="uploadURI"  :show-file-list="false" :on-success="handleLogoSuccess">
   <img v-if="unewdata.owe_show_group_logo" :src="unewdata.owe_show_group_logo" class="avatar">
    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  </el-upload>
<el-dialog :visible.sync="dialogVisible" size="tiny">
  <img width="100%" :src="dialogImageUrl" alt="">
</el-dialog>
    </el-form-item>


     <el-form-item label="主题色:">

            <el-input v-model="unewdata.owe_group_color" auto-complete="off"   type="color"   class="handle-input"></el-input>

    </el-form-item>

    <el-form-item label="战队简介:">
      <el-input v-model="unewdata.owe_group_content" auto-complete="off"   type="text"  placeholder="战队简介信息"  class="handle-input"></el-input>
    </el-form-item>
 <el-form-item label="荣誉值:">
      <el-input v-model="unewdata.owe_group_admire" auto-complete="off"   type="text"  placeholder="战队简介信息"  class="handle-input"></el-input>
    </el-form-item>
  </el-form>
  <div slot="footer" class="dialog-footer">
    <el-button  type="danger" @click="updateMinfo">保存</el-button>
  </div>


    </div>
</template>

<script>
import * as Login from '../../service/login'
import * as rpConfig from '../../../rpConfig/constant'
import { HttpReq } from '../../service/server'
var Server = new HttpReq()
export default {
    data: () => ({
        uploadURI: rpConfig.API_URI + '/Helpapi/uploadImg',
        dialogImageUrl: '',
        dialogVisible: false,
        unewdata: {
            owe_group_id: 0,
            owe_group_title: '',
            owe_group_img: '',
            owe_show_group_img:'',
            owe_group_logo: '',
            owe_show_group_logo:'',
            owe_group_content: '',
            owe_group_color: '',
            owe_group_admire: '',
   
        }
    }),
    methods: {


        handleCoverSuccess(res) {
    
            if (res.code != 200) {
                this.$message.error(res.msg)
            } else {
                this.unewdata.owe_show_group_img = res.data.url
                this.unewdata.owe_group_img = res.data.saveUrl
            }
        },
        handleLogoSuccess(res) {
    
            if (res.code != 200) {
                this.$message.error(res.msg)
            } else {
                this.unewdata.owe_show_group_logo = res.data.url
                this.unewdata.owe_group_logo = res.data.saveUrl
            }
        },
        getTeamInfo(teamid){
            let self = this
            Server._POST(
                rpConfig.API_URI + '/oweset.Index/getTeamDetail',
                {group_id:teamid},
                function(data) {

                    self.unewdata.owe_group_id=data.data.owe_group_id
                    self.unewdata.owe_group_title=data.data.owe_group_title
                    self.unewdata.owe_show_group_img=data.data.owe_show_group_img
                    self.unewdata.owe_show_group_logo=data.data.owe_show_group_logo
                    self.unewdata.owe_group_img=data.data.owe_group_img
                    self.unewdata.owe_group_logo=data.data.owe_group_logo
                    self.unewdata.owe_group_content=data.data.owe_group_content
                    self.unewdata.owe_group_color=data.data.owe_group_color
                    self.unewdata.owe_group_admire=data.data.owe_group_admire
                
                }
            )
        },
        updateMinfo() {
            let self = this
            Server._POST(
                rpConfig.API_URI + '/oweset.Index/updateTeamInfo',
                self.unewdata,
                function(data) {
                    self.$message.success(data.msg)
                    setTimeout(() => {
                        self.$router.push('/teamset')
                    }, 2000)
                }
            )
        }
    },
    mounted() {
      
        let teamId = this.$route.params.groupdId
        if(teamId){
            this.getTeamInfo(teamId)
        }
        else{
            this.$router.push('/')
        }
        
    }
}
</script>

<style>
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9c2;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}

.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>

</style>


